from threading import Thread

num = 0
count = 1000000
def add1():
    global num
    print(f"add1的初始值为{num}")
    for i in range(count):
        num+=1
    print(f"add1的最终值为{num}")

def add2():
    global num
    print(f"add2的初始值为{num}")
    for i in range(count):
        num+=1
    print(f"add2的最终值为{num}")

if __name__ == '__main__':
    t1 = Thread(target=add1)
    t2 = Thread(target=add2)
    t1.start()
    t1.join()  # 阻塞主线程
    t2.start()